<template>
  <view class="b_flower_scene_category_edit_container">
    <view class="example">
      <uni-forms ref="form" :model="form" labelWidth="80px">
            <uni-forms-item label="场景名称" name="sceneName" required >
              <uni-easyinput v-model="form.sceneName" placeholder="请输入场景名称" />
            </uni-forms-item>
            <uni-forms-item label="场景图标地址" name="sceneIcon"  >
              <uni-easyinput v-model="form.sceneIcon" placeholder="请输入场景图标地址" />
            </uni-forms-item>
            <uni-forms-item label="排序" name="sort"  >
              <uni-easyinput v-model="form.sort" placeholder="请输入排序" />
            </uni-forms-item>
            <uni-forms-item label="删除标识" name="delFlag"  >
              <uni-easyinput v-model="form.delFlag" placeholder="请输入删除标识" />
            </uni-forms-item>
      </uni-forms>
      <view class="button-group">
        <button type="default" style="padding:0 3em;font-size:14px"  class="button" @click="cancel">取消</button>
        <button type="primary" style="padding:0 3em;font-size:14px"  class="button" @click="submit">提交</button>
      </view>
    </view>
  </view>
</template>


<script>
import { updateCategory,getCategory,listCategory } from "@/api/category/category";
    import {getSelectDict} from "@/utils/dict";
export default {
  components: {
  },
  data() {
    return {
          //字典类型筛选options
    form: {},
    rules: {
                  sceneName: {
              rules: [{ required: true, errorMessage: "场景名称不能为空" }]
            },
                    }
    }
  },
onLoad(option) {
      //字典类型查询
  //鲜花场景分类详细
  this.getCategoryInfo(option.id);
},
  onReady() {
    this.$refs.form.setRules(this.rules)
  },
  methods: {
    /* 获取鲜花场景分类详情*/
    getCategoryInfo(id) {
      getCategory(id).then(response => {
        this.form = response.data;
      })
    },
/* 提交*/
submit() {
  this.$refs.form.validate().then(res => {
    updateCategory(this.form).then(response => {
      this.$modal.msgSuccess("编辑成功")
      setTimeout(() => {
        // 返回到上一级父页面
        this.$tab.navigateBack();
      },500)
    })
  })
},
/* 取消*/
cancel(){
  this.$tab.navigateBack();
}
}
}
</script>

<style lang="scss">
  page {
    background-color: #ffffff;
  }

  .b_flower_scene_category_edit_container {
    .example {
      padding: 15px;
      background-color: #fff;
    }

    .button-group {
      margin-top: 15px;
      display: flex;
      justify-content: space-around;
    }
  }
</style>